package DataBase;

import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Vector;

import DataObjects.Supplier;

public class AddItemToSupplier {
	
	private Vector<String> item_prices;            //ordered by iid,suppId, price
	private int status=0;
	
	
	



	public AddItemToSupplier(Vector<String> ItemsAndPrices)
	{
		
		this.item_prices=ItemsAndPrices;
		
		
	}

	
	
	public void saveNewItemToSupp()
	{
		SQLConnection sc=new SQLConnection();
		try {
			
				
			PreparedStatement ps1 = sc.getConnection().prepareStatement("INSERT INTO Supplier_item(iid,suppId,suppItemPrice) values(?,?,?);");				
			sc.getConnection().setAutoCommit(false);
			
			
			
			ps1.setString(1,(String) item_prices.get(0));
			ps1.setString(2,(String) item_prices.get(1));
			ps1.setString(3,(String) item_prices.get(2));
			ps1.executeUpdate();
			sc.getConnection().commit();
			status=1;
			ps1.close();
			sc.getConnection().close();
			
				
					
		}
		
		catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		}
		
		
	public int getStatus() {
		return status;
	}



	public void setStatus(int status) {
		this.status = status;
	}
		
	}

